package com.medistat.model;

import java.util.Calendar;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import org.hibernate.annotations.GenericGenerator;

import com.medistat.model.enums.Days;
import com.medistat.model.enums.TypeOfWork;

@Entity
public class Work extends StandardPersistentObject {
	
	@Id @GeneratedValue(generator="ID_GENERATOR_FOR_DAYINWEEK")
	@GenericGenerator(name="ID_GENERATOR_FOR_DAYINWEEK", strategy = "increment")
	private Long id;
	
	private Calendar date;
	private Days day;
	
	//parent reference
	@ManyToOne(targetEntity=Schedule.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="ScheduleID", referencedColumnName="ID") })	
	@Basic(fetch=FetchType.LAZY)
	private Schedule schedule;
	
	
	//single relationship
	@OneToOne
	private Doctor doctor;
	
	@Enumerated(EnumType.STRING)
	private TypeOfWork typeOfWork;

	public Long getId() {
		return id;
	}

	public Schedule getSchedule() {
		return schedule;
	}

	public void setSchedule(Schedule schedule) {
		this.schedule = schedule;
	}

	public Doctor getDoctor() {
		return doctor;
	}

	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
	}

	public TypeOfWork getTypeOfWork() {
		return typeOfWork;
	}

	public void setTypeOfWork(TypeOfWork typeOfWork) {
		this.typeOfWork = typeOfWork;
	}

	public Days getDay() {
		return day;
	}

	public void setDay(Days day) {
		this.day = day;
	}

	public Calendar getDate() {
		return date;
	}

	public void setDate(Calendar date) {
		this.date = date;
	}
}
